package com.hframe.log;

import org.apache.log4j.Level;
import org.apache.log4j.net.SyslogAppender;

/**
 * Sql 输出日志
 * 
 * @author heqian
 *
 */
public class SqlLevel extends Level {
	public final static int SQL_INT = 5000;
	public static final SqlLevel SQL = new SqlLevel(SQL_INT, "SQL", SyslogAppender.LOG_LOCAL0);

	protected SqlLevel(int level, String levelStr, int syslogEquivalent) {
		super(level, levelStr, syslogEquivalent);
	}

	public static Level toLevel(String sArg) {
		return (Level) toLevel(sArg, Level.DEBUG);
	}

	public static Level toLevel(int val) {
		return (Level) toLevel(val, Level.DEBUG);
	}

	public static Level toLevel(int val, Level defaultLevel) {
		if (val == SQL_INT)
			return SQL;

		return Level.toLevel(val, defaultLevel);
	}

	public static Level toLevel(String sArg, Level defaultLevel) {
		if ("SQL".equals(sArg.toUpperCase()))
			return SQL;

		return Level.toLevel(sArg, defaultLevel);
	}
}
